﻿/***********************************************/
//当前页面实例
var currentPage;
//控件集合实例
var controlsCollection;
//命名空间
 var PageList;

 //页面加载完成
 $(document).ready(function () {
     var collection = [
        New(ASPxRFTextBox, ['txtPageCode', ['GroupA'], 'PageCode']),
        New(ASPxRFTextBox, ['txtPageName', ['GroupA'], 'PageName']),
        New(ASPxRFComboBox, ['cbModule', ['GroupA'], { textField: 'ModuelName', valueField: 'ModuleKeyid'}])
    ];

     controlsCollection = New(RapidForm, [collection]);
     //页面简写
     PageList = SGDemo.Permission.PageList;

     //声明页面信息
     var navigationInfo = { moduleValue: 'Permission', itemValue: 'PageItem', itemName: '页面明细' };
     currentPage = New(RFPage, [menuHeader, gvwList, ['btnEdit', 'btnView'], [ 'btnDelete'], null, navigationInfo]);
     currentPage.firstLoad();
 });
 //检索
 var doSearch = function () {
     currentPage.toSearch();
     doDisplay("search");
     txtPageCode.Focus();
 }
 //显示列表
 var doListAll = function () {
     currentPage.toListAll();
     doDisplay("listall");
 }

 /***********************************************/
 //GridView选中全部或者取消选中全部
 var doSelectOrUnselectAll = function (s, e) {
     gvwList.SelectAllRowsOnPage(s.GetChecked());
 }
 //GridView选择事件
 function doSelectionChanged() {
     currentPage.selectionChanged();
 }
 //GridView双击行打开明细
 function doRowDblClick(s, e) {
     currentPage.rowDblClick(s, e);
 }
 //查询
 function doSubmittedToSearch(s, e) {
  
     $('#hfFilterCondition').val(controlsCollection.getQueryString('GroupA'));
     gvwList.PerformCallback();
     doListAll();
     menuHeader.SetSelectedItem(menuHeader.GetItemByName('btnListAll'));
 }
 //重置
 var doResetToSearch = function () {
     controlsCollection.reset('GroupA');
 }
 //查看
 var doView = function () {
     currentPage.toView();
 }
 //编辑
 var doEdit = function () {
     currentPage.toEdit();
 }
 //新增
 var doAdd = function () {
     currentPage.toAdd();
 }
 //刷新
 var doRefresh = function () {
     gvwList.PerformCallback();
 }
 //*************************************//
 //删除
 var doDelete = function () {
     $.messager.confirm('确认提示', '确认删除吗?', function (result) {
         if (result) {
             //获取选择记录Keyids
             var keyid = gvwList.GetSelectedKeysOnPage().join('_');
             //调用删除方法
             PageList.Delete(keyid, function (result) {
                 if (result.value) {
                     gvwList.PerformCallback();
                     $.messager.show({
                         title: '信息提示',
                         msg: '删除成功！',
                         showType: 'slide'
                     });

                 } else {
                     $.messager.show({
                         title: '信息提示',
                         msg: '删除失败！',
                         showType: 'slide'
                     });
                 }
             });
         }
     });
 }
 //导出
 var doExport = function () {
     pcExport.Show();
 }

 //关闭导出
 var doCloseToExport = function () {
     pcExport.Hide();
 }

 //添加快捷方式
 var doSetShortcut = function () {
     SGDemo.Permission.PageList.SaveFastAdd(function (result) {
         if (result.value) {
             $.messager.show({
                 title: '信息提示',
                 msg: '添加快捷方式成功！',
                 showType: 'slide'
             });

         } else {
             $.messager.show({
                 title: '信息提示',
                 msg: '添加快捷方式失败！',
                 showType: 'slide'
             });
         }

     });
 }

 //导出
 var doExport = function () {
     SGDemo.Permission.PageList.ExportPageList(function (result) {
         window.open("../../../" + result.value, "PageList");
     });
 }

 //导入
 var doImport = function () {
     Shadowbox.open({
         content: '../../../Views/Permission/Popup/ImportPageData.aspx',
         player: 'iframe',
         title: '导入页面数据',
         height: 340,
         width: 720
     });
 }
